/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "DISTRITO")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Distrito.findAll", query = "SELECT d FROM Distrito d"),
    @NamedQuery(name = "Distrito.findByDistCod", query = "SELECT d FROM Distrito d WHERE d.distCod = :distCod"),
    @NamedQuery(name = "Distrito.findByDistNom", query = "SELECT d FROM Distrito d WHERE d.distNom = :distNom")})
public class Distrito implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "DIST_COD")
    private Integer distCod;
    @Column(name = "DIST_NOM")
    private String distNom;
    @OneToMany(mappedBy = "distCod", fetch = FetchType.LAZY)
    private List<Alumno> alumnoList;

    public Distrito() {
    }

    public Distrito(Integer distCod) {
        this.distCod = distCod;
    }

    public Integer getDistCod() {
        return distCod;
    }

    public void setDistCod(Integer distCod) {
        this.distCod = distCod;
    }

    public String getDistNom() {
        return distNom;
    }

    public void setDistNom(String distNom) {
        this.distNom = distNom;
    }

    @XmlTransient
    public List<Alumno> getAlumnoList() {
        return alumnoList;
    }

    public void setAlumnoList(List<Alumno> alumnoList) {
        this.alumnoList = alumnoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (distCod != null ? distCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Distrito)) {
            return false;
        }
        Distrito other = (Distrito) object;
        if ((this.distCod == null && other.distCod != null) || (this.distCod != null && !this.distCod.equals(other.distCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.Distrito[ distCod=" + distCod + " ]";
    }
    
}
